from django.conf.urls.defaults import *
from projectadmin.projects.models import *

aims_dict = {
  'queryset' : Aim.objects.all(),
}

deliverables_dict = {
  'queryset' : Deliverable.objects.all(),
}

objectives_dict = {
  'queryset' : Objective.objects.all(),
}

project_dict = {
  'queryset' : Project.objects.all(),
}

person_dict = {
  'queryset' : Person.objects.all(),
}

tasks_dict = {
  'queryset' : Task.objects.all(),
}

work_package_dict = {
    'queryset': WorkPackage.objects.all(),
}

urlpatterns = \
    patterns('',

    url(r'^$', 'django.views.generic.list_detail.object_list', project_dict, "project_home"),
    url(r'^add/$', 'projects.views.project_form', name="add_project"),
    url(r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', project_dict, "project_detail"),
    url(r'^(?P<project_id>\d+)/addWorkPackage/$', 'projects.views.work_package_form', name="project_add_work_package"),    

    url(r'^workPackages/$', 'django.views.generic.list_detail.object_list', work_package_dict, "work_package_list"),
    url(r'^workPackage/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', work_package_dict, "work_package_detail"),
    url(r'^workPackage/(?P<wp_id>\d+)/addAim/$', 'projects.views.aim_form', name="work_package_add_aim"),    

    url(r'^aims/$', 'django.views.generic.list_detail.object_list', aims_dict, "aim_list"),
    url(r'^aim/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', aims_dict, "aim_detail"),
    url(r'^aim/(?P<aim_id>\d+)/addObjective/$', 'projects.views.objective_form', name="aim_add_objective"),    

    url(r'^objectives$', 'django.views.generic.list_detail.object_list', objectives_dict, "objective_list"),
    url(r'^objective/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', objectives_dict, "objective_detail"),
    url(r'^objective/(?P<objective_id>\d+)/edit/$', 'projects.views.objective_form', name="objective_edit"),   
    url(r'^objective/(?P<objective_id>\d+)/addTask/$', 'projects.views.task_form', name="objective_task_add"),    
    url(r'^objective/(?P<objective_id>\d+)/addDeliverable/$', 'projects.views.deliverable_form', name="objective_add_deliverable"),    

    url(r'^deliverables$', 'projects.views.incomplete_deliverable_list', name="deliverable_list"),
    url(r'^deliverable/add/$', 'projects.views.deliverable_form', name="add_deliverable"),
    url(r'^deliverable/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', deliverables_dict, "deliverable_detail"),
    url(r'^deliverable/(?P<deliverable_id>\d+)/requestUpdate/$', 'projects.views.requestDeliverableUpdate', name="request_deliverable_update"),
    url(r'^deliverable/(?P<deliverable_id>\d+)/setComplete/$', 'projects.views.deliverableSetComplete', name="deliverable_set_complete"),    
    url(r'^deliverable/(?P<deliverable_id>\d+)/addTask/$', 'projects.views.task_form', name="deliverable_task_add"),    
    url(r'^deliverable/(?P<deliverable_id>\d+)/edit/$', 'projects.views.deliverable_form', name="deliverable_edit"),
    url(r'^deliverable/tagged/(?P<tag_name>.+)/$', 'projects.views.tagged_deliverable', name="project_tagged_deliverable"),

    url(r'^tasks$', 'projects.views.incomplete_task_list', name="task_list"),
    url(r'^task/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', tasks_dict, "task_detail"),
    url(r'^task/(?P<task_id>\d+)/requestUpdate/$', 'projects.views.requestTaskUpdate', name="request_task_update"),
    url(r'^task/(?P<task_id>\d+)/setComplete/$', 'projects.views.taskSetComplete', name="task_set_complete"),    
    url(r'^task/add/$', 'projects.views.task_form', name="task_add"),
    url(r'^task/add/subtaskOf/(?P<parent_id>\d+)/$', 'projects.views.task_form', name="task_add_subTask"),
    url(r'^task/(?P<task_id>\d+)/edit/$', 'projects.views.task_form', name="task_edit"),
    url(r'^task/tagged/(?P<tag_name>.+)/$', 'projects.views.tagged_task', name="project_tagged_task"),
    
    url(r'^people$', 'django.views.generic.list_detail.object_list', person_dict, "people_list"),
    url(r'^person/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', dict(person_dict, template_name="projects/person_summary.html"), "person_summary" ),
    url(r'^person/(?P<object_id>\d+)/detail$', 'django.views.generic.list_detail.object_detail', person_dict, "person_detail"),
    url(r'^person/(?P<object_id>\d+)/calendar$', 'projects.views.person_calendar', name="project_person_calendar"),
    url(r'^person/(?P<person_id>\d+)/toEstimate$', 'projects.views.person_to_estimate', name="project_person_toEstimate"),

    url(r'^report$', 'projects.views.completed', name="project_report_completed"),
    url(r'^report/weekly$', 'projects.views.weekly_report', name="project_weekly_report"),
    url(r'^report/recentlyCompleted$', 'projects.views.completed', name="project_report_completed"),

    url(r'^search$', 'projects.views.search_form', name="project_search"),
  )
